package com.ruoyi.web.controller.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import com.ruoyi.system.domain.res.projectCheck.ProjectCheckList_union_res;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectCheck;
import com.ruoyi.system.service.IProjectCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 竞标项目检查Controller
 *
 * @author ruoyi
 * @date 2025-09-22
 */
@RestController
@RequestMapping("/system/projectCheck")
public class ProjectCheckController extends BaseController {
    @Resource
    private IProjectCheckService projectCheckService;

    /**
     * 查询竞标项目检查列表
     */
    //@PreAuthorize("@ss.hasPermi('system:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectCheck projectCheck) {
        startPage();
        List<ProjectCheck> list = projectCheckService.selectProjectCheckList(projectCheck);
        return getDataTable(list);
    }

    /**
     * 查询竞标项目检查列表_back
     */
    //@PreAuthorize("@ss.hasPermi('system:check:list')")
    @GetMapping("/list_back")
    public TableDataInfo list_back(ProjectCheck projectCheck) {
        startPage();
        ProjectCheckList_union_res unionRes = projectCheckService.selectProjectCheckList_back(projectCheck);
        TableDataInfo dataTable = getDataTable(unionRes.getResList());
        dataTable.setTotal(new PageInfo<>(unionRes.getList()).getTotal());
        return dataTable;
    }

    /**
     * 导出竞标项目检查列表
     */
    //@PreAuthorize("@ss.hasPermi('system:check:export')")
    @Log(title = "竞标项目检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectCheck projectCheck) {
        List<ProjectCheck> list = projectCheckService.selectProjectCheckList(projectCheck);
        ExcelUtil<ProjectCheck> util = new ExcelUtil<ProjectCheck>(ProjectCheck.class);
        util.exportExcel(response, list, "竞标项目检查数据");
    }

    /**
     * 获取竞标项目检查详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectCheckService.selectProjectCheckById(id));
    }

    /**
     * 获取竞标项目检查详细信息_back
     */
    //@PreAuthorize("@ss.hasPermi('system:check:query')")
    @GetMapping(value = "/getInfo_back/{id}")
    public AjaxResult getInfo_back(@PathVariable("id") Long id) {
        return success(projectCheckService.selectProjectCheckById_back(id));
    }

    /**
     * 新增竞标项目检查
     */
    //@PreAuthorize("@ss.hasPermi('system:check:add')")
    @Log(title = "竞标项目检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectCheck projectCheck) {
        return toAjax(projectCheckService.insertProjectCheck(projectCheck));
    }

    /**
     * 修改竞标项目检查
     */
    //@PreAuthorize("@ss.hasPermi('system:check:edit')")
    @Log(title = "竞标项目检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectCheck projectCheck) {
        return toAjax(projectCheckService.updateProjectCheck(projectCheck));
    }

    /**
     * 删除竞标项目检查
     */
    //@PreAuthorize("@ss.hasPermi('system:check:remove')")
    @Log(title = "竞标项目检查", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectCheckService.deleteProjectCheckByIds(ids));
    }
}
